﻿using System;
using System.Data;
using DataAccess;
using EntitiesTM;

namespace Business
{
    public class BuTimeDay
    {
        public static DataTable selRegisterDay(string date, string email, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            return timeDay.selRegisterDay(date, email, companyid);
        }

        public static int checkRegisterDay(string date, string email, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            return timeDay.checkRegisterDay(date, email, companyid);
        }

        public static int selStaffIDByEmail(string email, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            return Int32.Parse(timeDay.selStaffIDByEmail(email, companyid).Rows[0]["StaffID"].ToString());
        }

        public static EnSA selRegisterByID(int saID, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            EnSA sa = new EnSA();
            DataRow dtTmp = timeDay.selRegisterByID(saID, companyid).Rows[0];
            try
            {
                sa.saStaffID = Int32.Parse(dtTmp["SAStaffID"].ToString());
                sa.saActivityID = Int32.Parse(dtTmp["SAActivityID"].ToString());
                sa.saDate = DateTime.Parse(dtTmp["SADate"].ToString());
                sa.saDetails = dtTmp["SADetails"].ToString();
                sa.saTimeReportHour = Int32.Parse(dtTmp["SAReportTimeHour"].ToString());
                sa.saTimeReportMinute = Int32.Parse(dtTmp["SAReportTimeMinute"].ToString());
                sa.saIsFinish = Boolean.Parse(dtTmp["SAIsFinish"].ToString());
            }
            catch { }
            return sa;
        }

        public static void updRegisterDay(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.updRegisterDay(sa, companyid);
        }

        public static void updRegisterDay2(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.updRegisterDay2(sa, companyid);
        }

        public static void updRegisterDayFinish(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.updRegisterDayFinish(sa, companyid);
        }

        public static void delRegisterDay(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.delRegisterDay(sa, companyid);
        }

        public static void insRegisterDay(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.insRegisterDay(sa, companyid);
        }

        public static void insRegisterDay2(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.insRegisterDay2(sa, companyid);
        }

        public static void insRegisterWeek(EnSA sa, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            timeDay.insRegisterDayWeek(sa, companyid);
        }

        public static DataTable selRegisterWeekCopy(string date, string email, string companyid)
        {
            DaTimeDay timeDay = new DaTimeDay();
            return timeDay.selRegisterWeekCopy(date, email,companyid);
        }
    }
}
